package avicit.bdp.dgs.metadata.rest;

import avicit.bdp.dgs.metadata.dto.MetadataTmpDTO;
import avicit.bdp.dgs.metadata.service.MetadataTmpService;
import avicit.platform6.core.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "元数据编辑")
@RequestMapping("/api/bdp/dgs/metadata/tmp")
public class MetadataTmpRest {

  @Resource private MetadataTmpService metadataTmpService;

  @ApiOperation(value = "通过元数据ID查询")
  @ApiParam(value = "元数据ID", name = "metadataId", required = true)
  @GetMapping("/{metadataId}")
  public ResponseMsg<MetadataTmpDTO> queryByMetadataId(@PathVariable String metadataId) {
    ResponseMsg<MetadataTmpDTO> responseMsg = new ResponseMsg<>();
    responseMsg.setResponseBody(metadataTmpService.queryByMetadataId(metadataId));
    return responseMsg;
  }

  @ApiOperation(value = "发布")
  @ApiParam(value = "元数据ID", name = "metadataId", required = true)
  @GetMapping(value = "/publish/{metadataId}")
  public ResponseMsg<Boolean> update(@PathVariable String metadataId) {
    ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
    responseMsg.setResponseBody(metadataTmpService.publish(metadataId));
    return responseMsg;
  }
}
